import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class APServer extends JFrame {
	
	static String version = "APSUV0.7 BUILD6-18-11";
	
	JTextArea console = new JTextArea(40,40);
	JTextField line = new JTextField(33);
	public JPasswordField validate = new JPasswordField(10);
	JLabel prompt = new JLabel("ADMIN>");
	APSUEngine engine;
	public server serv=null;

	public APServer() {
		
		super(version + " : antonym private server utility");
		setSize(503,250);
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		setResizable(true);
		setLocation(0, 525);
		
		JOptionPane.showMessageDialog(null, version + "\n\nYour validation MUST be in the pink field to submit commands.\nPlease exit with the EXIT command.","APSUv0.7", JOptionPane.INFORMATION_MESSAGE);
		
		engine = new APSUEngine(this);
		
		BorderLayout layout = new BorderLayout();
		setLayout(layout);
		
		Font consoleFont = new Font("Proxy 1", 12, 12);
		console.setFont(consoleFont);
		
		console.setBackground(Color.black);
		console.setForeground(Color.CYAN);
		console.setAutoscrolls(true);
		console.setWrapStyleWord(true);
		console.setText("_________________\n|*_:|:_*|*_:|:_*|*_:|:_*|\n|Antonym Private Server\n|CODE BY ZEN [6-14-11]\n|*_:|:_*|*_:|:_*|*_:|:_*|\nVVVVVVVVVVVVV");		
		console.setEditable(false);
		add(console,BorderLayout.CENTER);
		
		JScrollPane scroll = new JScrollPane(console, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		add(scroll);
		
		JPanel tool = new JPanel();
		tool.setBackground(Color.blue);
		tool.setForeground(Color.cyan);
		
		line.setBackground(Color.BLACK);
		line.setForeground(Color.WHITE);
		line.addKeyListener(engine);
		line.setFont(consoleFont);
		
		validate.setBackground(new Color(255,50,150));
		
		prompt.setFont(consoleFont);
		prompt.setForeground(Color.WHITE);
		tool.add(prompt);
		
		tool.add(line);
		tool.add(validate);
		
		add(tool, BorderLayout.SOUTH);
		
		setVisible(true);
		
		//Uncomment to start server at startup
		@SuppressWarnings("unused")
		server serv = new server(this);
		
	}
	
	public static void main(String[] args) {
		
		@SuppressWarnings("unused")
		APServer frame = new APServer();
		
	}
	
	public void toConsole(String send) {
		
		console.setText(console.getText() + "\n" + send);
		
	}
	
	public void popup(String message, String title) {
		
		JOptionPane.showMessageDialog(null, version + "\n" + message,title, JOptionPane.PLAIN_MESSAGE);
		
	}
	
	public void initServer() {
		
		serv = new server(this);
		return;
		
	}
	
	public boolean proxy() {
		
		initServer();
		return true;
		
	}
	
	public void stopServer() {
		
		//serv.trip=true;
		
	}
	

}
